package com.google.android.exoplayer2.decoder;

import java.nio.ByteBuffer;
import o.acv;
import o.acw;

public class DecoderInputBuffer extends acw {
    private final int ˊ;
    public final acv ˋ = new acv();
    public long ˏ;
    public ByteBuffer ॱ;

    public static DecoderInputBuffer ˋ() {
        return new DecoderInputBuffer(0);
    }

    public DecoderInputBuffer(int i) {
        this.ˊ = i;
    }

    public void ˊ(int i) {
        if (this.ॱ == null) {
            this.ॱ = ॱॱ(i);
            return;
        }
        int capacity = this.ॱ.capacity();
        int position = this.ॱ.position();
        int i2 = position + i;
        if (capacity < i2) {
            ByteBuffer ॱॱ = ॱॱ(i2);
            if (position > 0) {
                this.ॱ.position(0);
                this.ॱ.limit(position);
                ॱॱ.put(this.ॱ);
            }
            this.ॱ = ॱॱ;
        }
    }

    public final boolean ʼ() {
        return this.ॱ == null && this.ˊ == 0;
    }

    public final boolean ʻ() {
        return ˏ(1073741824);
    }

    public final void ᐝ() {
        this.ॱ.flip();
    }

    public void ˊ() {
        super.ˊ();
        if (this.ॱ != null) {
            this.ॱ.clear();
        }
    }

    private ByteBuffer ॱॱ(int i) {
        if (this.ˊ == 1) {
            return ByteBuffer.allocate(i);
        }
        if (this.ˊ == 2) {
            return ByteBuffer.allocateDirect(i);
        }
        throw new IllegalStateException("Buffer too small (" + (this.ॱ == null ? 0 : this.ॱ.capacity()) + " < " + i + ")");
    }
}
